import random
import time

RoomNum = []
class Role(object):
    def __init__(self, name, sex, blood, outfit):
        self.name = name
        self.sex = sex
        self.blood = blood
        self.outfit = outfit

    def defense(self, role):
        if role.outfit == "锁子甲":
            if role.blood < 100:
                role.blood += 5
        elif role.outfit == "板甲":
            if role.blood < 100:
                role.blood += 8

    def attack(self, role):
        print("普通攻击!")
        role.blood -= 10


class Room(object):

    def __init__(self, name):
        self.name = name

    def joinRoom(self):
        if self.name == '101':
            RoomNum.append('role')
            if len(RoomNum) == 2:
                print("房间已满，开始战斗!")
        if self.name != '101':
            raise BaseException("房间未开放，输入错误！")


class Skill(Role):
    def skill1(self, role):
        print("摄魂夺魄!")
        role.blood -= 20

    def skill2(self, role):
        print("魅惑妖术!")
        role.blood -= 15

    def skill3(self, role):
        print("灵魂突袭!")
        role.blood -= 30

    def skill4(self, role):
        print("飞星乱入!")
        role.blood -= 35

    def skill5(self, role):
        print("烟火四射!")
        role.blood -= 15


if __name__ == '__main__':
    memberNum = 0
    role1 = Skill(input("请输入角色1名："), input("请输入角色1性别："), 100, input("请输入角色1装备(锁子甲/板甲)："))
    Room(input("请输入房间名（目前只开放101房间）：")).joinRoom()
    role2 = Skill(input("请输入角色2名："), input("请输入角色2性别："), 100, input("请输入角色2装备(锁子甲/板甲)："))
    Room(input("请输入房间名（目前只开放101房间）：")).joinRoom()

print("准备中...")
time.sleep(2)
round = 1

while True:
    print(f"第{round}回合".center(25, "*"))
    num = random.randint(0, 5)
    print(f"{role1.name}释放技能：", end="")
    if num == 0:
        role2.attack(role2)
    elif num == 1:
        role2.skill1(role2)
    elif num == 2:
        role2.skill2(role2)
    elif num == 3:
        role2.skill3(role2)
    elif num == 4:
        role2.skill4(role2)
    else:
        role2.skill5(role2)
    role2.defense(role2)

    num = random.randint(0, 5)
    print(f"{role2.name}释放技能：", end="")
    if num == 0:
        role1.attack(role1)
    elif num == 1:
        role1.skill1(role1)
    elif num == 2:
        role1.skill2(role1)
    elif num == 3:
        role1.skill3(role1)
    elif num == 4:
        role1.skill4(role1)
    else:
        role1.skill5(role1)
    role1.defense(role1)
    print("-" * 25)
    print(f"{role1.name}的血量：{role1.blood}    {role2.name}的血量：{role2.blood}")
    round += 1
    print(f"本回合结束".center(25, "*"))
    print("\n")
    if role1.blood <= 0 or role2.blood <= 0:
        if role1.blood <= 0 and role2.blood > 0:
            print(f"{role2.name}  win!!!!".center(25, "*"))
        elif role2.blood <= 0 and role1.blood > 0:
            print(f"{role1.name}  win!!!!")
        elif role1.blood <= 0 and role2.blood <= 0:
            print("双方平手！")
        break
    time.sleep(1)
